--[[
编码:
名称:
作者:
日期:2024-08-26
函数: GenerateViewHTML
功能:
更改记录:
--]] json = require("json")
mobox = require("OILua_JavelinExt")
m3 = require("oi_base_mobox")
function GenerateViewHTML(strLuaDEID)
local nRet, strRetInfo
--[[ 列明 ]]
local taCol = {"", "已用", "剩余"}
local strCol = ""
for i = 1, #taCol do
strCol = strCol ..
"
" ..
taCol[i] .. " | "
end
--[[ 行数据 ]]
-- local tbRow = {{"片胶", 10, 20}, {"块胶", 10, 20}, {"粉胶", 10, 20}}
--[[ 第一列向下合并行数 ]]
-- local nRowSpan = #tbRow + 1
-- local strRow = ""
-- for i = 1, #tbRow do
-- local tbR = tbRow[i]
-- strRow = strRow .. ''
-- for j = 1, #tbR do
-- strRow = strRow ..
-- ' ' ..
-- tbR[j] .. ' | '
-- end
-- strRow = strRow .. '
'
-- end
-- 获取所有机台编码
local area
local strCondition = "S_CODE LIKE '%CMB%' AND S_CODE NOT LIKE '%DP%'" -- 通过什么条件筛选机台
nRet, area = m3.QueryDataObject(strLuaDEID, "Area", strCondition)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取机台信息失败!" .. area)
end
if (area == "" or area == nil) then
lua.Error(strLuaDEID, debug.getinfo(1), "根据条件" .. strCondition .. "未获取到机台信息!")
end
lua.Debug(strLuaDEID,debug.getinfo(1),"area!",area)
local strTbsHtml = ""
for i = 1, #area do
local kjcondtion = "S_CODE LIKE '%RC%'" -- 块胶判断条件
local pjcondtion = "S_CODE LIKE '%PB%'" -- 块胶判断条件
local fjcondtion = "S_CODE LIKE '%PM%'" -- 块胶判断条件
-- 通过库区机台编码获取对应的货位使用情况
local kjyy_count, kjwy_count, pjyy_count, pjwy_count, fjyy_count, fjwy_count
-- 块胶数量查询
local strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM <> 0 AND " .. kjcondtion
nRet, kjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. kjyy_count)
end
strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM = 0 AND " .. kjcondtion
nRet, kjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. kjwy_count)
end
-- 片胶数量查询
strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM <> 0 AND " .. pjcondtion
nRet, pjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. pjyy_count)
end
strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM = 0 AND " .. pjcondtion
nRet, pjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. pjwy_count)
end
-- 粉胶数量查询
strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM <> 0 AND " .. fjcondtion
nRet, fjyy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位已使用数量失败!" .. fjyy_count)
end
strCondtion = "S_AREA_CODE = '" .. m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE ..
"' AND N_CURRENT_NUM = 0 AND " .. fjcondtion
nRet, fjwy_count = mobox.getDataObjCount(strLuaDEID, "Location", strCondtion)
if (nRet ~= 0) then
lua.Error(strLuaDEID, debug.getinfo(1), "获取货位未使用数量失败!" .. fjwy_count)
end
strTbsHtml = strTbsHtml ..
'' ..
'' .. ' ' ..
'' ..
m3.KeyValueAttrsToObjAttr(area[i].attrs).S_CODE .. '机台 | ' .. strCol .. '
' ..
' 块胶 | ' ..
'' ..kjyy_count .. ' | ' ..
'' ..kjwy_count .. ' |
' ..
' 片胶 | ' ..
'' ..pjyy_count .. ' | ' ..
'' ..pjwy_count .. ' |
' ..
' 粉胶 | ' ..
'' ..
fjyy_count .. ' | ' ..
'' ..
fjwy_count .. ' |
'
.. ' ' .. '
'
end
-- local strTbsHtml = ""
-- for i = 1, 30 do
-- strTbsHtml = strTbsHtml ..
-- '' ..
-- '' .. ' ' ..
-- '' .. i ..
-- '号机台 | ' .. strCol .. '
' .. strRow .. ' ' .. '
'
-- end
local str_html = '' .. strTbsHtml .. '
'
local action = {{
action_type = "chart",
value = {
graphicType = "html",
title = {
text = "17号机台",
align = "left",
color = "#fff",
font = "微软雅黑",
fontSize = 18
},
html = str_html
}
}}
nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
if (nRet ~= 0) then
Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. ' action = ' .. strAction)
end
end